<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title></title> 
    <script>
        const electron = require('electron');
        const ipcRenderer = electron.ipcRenderer;
    </script>
    <script src="i18n/i18n.js"></script>
    <style>
        body{
            background-color: azure;
            color:  #446fbd;
        }
        #btn-ok{
            margin: 20px 40px;
            background-color:darkseagreen;
            color: white;
            font-size: 14px;
            padding: 6px 24px;
            cursor: pointer;
            box-shadow: 1px 1px 2px black;
            border-radius: 4px;
            cursor: pointer;
        }
        #btn-ok:hover{
            background-color:seagreen;
        }
        #btn-ok:active{
            box-shadow: 0px 0px 1px black;
        }
        #btn-container{
            text-align: center;
        }
    </style>
  </head>
  <body>
    <p>
        <span id="please-select-language"></span>
        <select id="select-language"></select>
    </p>
    <div id="btn-container">
        <a role="button" id="btn-ok"></a>
    </div>
    <script>
        // init i18n
        i18n.init();  
        document.title = i18n.prop("menu.switch-language");
        var props = i18n.props;
        // language options
        var languages = [];
        for(var key in props){
            var name = props[key].name;
            languages.push({
                value:key,
                text:name
            })
        }
        var innerHtml = "";
        for(var i=0;i<languages.length;i++){
            innerHtml += "<option value='"+languages[i].value+"'>"+languages[i].text+"</option>"
        }
        var selectLanguage = document.getElementById("select-language");
        selectLanguage.innerHTML = innerHtml;
        selectLanguage.value = i18n.options.language;
        // please-select-language
        document.getElementById("please-select-language").innerHTML = i18n.prop("please-select-language");
        document.getElementById("btn-ok").innerHTML = i18n.prop("switch-language.btn-ok");
        // ok
        document.getElementById("btn-ok").onclick = function(){
            i18n.setLanguage(selectLanguage.value);
            ipcRenderer.sendSync("change-language",null);
        }
    </script>
  </body>
</html>